-- prop
-- created by dengc
-- 刷新工程学手册赋予的属性

return {
    -- 学习知识点
    apply = function(id, info)
        -- 刷新
        PropM.refreshEffect(ME.user, "engineering_manual");
    end,

    -- 使用道具
    useProperty = function(target, bonusId, info)
        local dbase = EngineeringManualM.queryBonus(bonusId, "dbase") or {};
        local path = dbase["prop_path"];
        if not path then
            path = "mixed";
        end
        
        local round = CombatM.getRound();

        -- 普通属性
        if type(info[1]) == "table" then
            for _, prop in pairs(info) do
                if prop[4] ~= -1 then
                    prop[4] = prop[4] + round + 1;
                end

                PropM.record(target, prop, path);
            end
        else
            -- 单条属性
            if info[4] ~= -1 then
                info[4] = info[4] + round + 1;
            end

            PropM.record(target, info, path);
        end

        -- 抛事件
        EventMgr.fire(event.ADD_PROP, { ["effect_id"] = dbase.effect_id, });
    end,

    -- 二级界面描述
    desc = function(id, info)
        local temp = "";

        local props = info;
        if type(props[1]) ~= "table" then
            props = { props, };
        end

        for _, prop in pairs(props) do
            local propDesc = PropM.getPropDesc(prop);
            if propDesc ~= "" then
                -- 匹配掉颜色信息
                propDesc = string.gsub(propDesc, "%[.-%]", "");

                temp = spliceLocStr(temp, propDesc .. "\n");
            end
        end

        return temp;
    end,
};
